package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IProjectRabateDao;
import com.financing.platform.dto.ProjectRabateDTO;
import com.financing.platform.util.SqlName;

@Repository("projectRabateDaoImpl")
public class ProjectRabateDaoImpl extends BaseDaoImpl implements
		IProjectRabateDao {

	public Integer insertProjectRabate(ProjectRabateDTO projectRabateDTO) {
		try {
			this.sqlMapClient.insert(SqlName.insertProjectRabate, projectRabateDTO);
		} catch (SQLException e) {
			log.error("Insert project rabate error!", e);
			return 0;
		}
		return 1;
	}

	@SuppressWarnings("unchecked")
	public List<ProjectRabateDTO> queryProjectRabateList(
			ProjectRabateDTO projectRabateDTO) {
		try {
			return (List<ProjectRabateDTO>)this.sqlMapClient.queryForList(SqlName.searchProjectRabateByPid, projectRabateDTO);
		} catch (SQLException e) {
			log.error("Query prject rabate error",e);
			return Collections.emptyList();
		}
	}

	public int deleteProjectRabate(Integer pid) throws SQLException {
		return this.sqlMapClient.delete(SqlName.deleteProjectRabate,pid);
	}

}
